from django.db import models

class EnvironmentData(models.Model):
    card_number = models.CharField(max_length=50)
    information = models.TextField()
    timestamp = models.DateTimeField(auto_now_add=True)
    
    @classmethod
    def clear_all_data(cls):
        """清除所有环境数据"""
        cls.objects.all().delete()

class CardData(models.Model):
    card_number = models.CharField(max_length=50)
    information = models.TextField()
    timestamp = models.DateTimeField(auto_now_add=True)
    is_registered = models.BooleanField(default=False)
    
    def __str__(self):
        return self.card_number
    
    @classmethod
    def clear_all_data(cls):
        """清除所有卡数据"""
        cls.objects.all().delete()

class CardList(models.Model):
    """存储卡片列表数据"""
    data = models.TextField()  # 存储JSON格式的卡片列表
    timestamp = models.DateTimeField(auto_now_add=True)
    
    class Meta:
        ordering = ['-timestamp']
